package com.scse.bms.service;

import java.util.List;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.scse.bms.domain.ThemeVO;
import com.scse.bms.entity.ThemeDO;
import com.scse.bms.domain.MenuItem;
import com.scse.bms.mapper.ThemeMapper;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;


/**
 * @Title: ThemeServiceImpl
 * @Author: 吴赠禹
 * @Date: 2021/2/20 0:09
 * @Version: 1.0
 * @Description: TODO
 */


@Service
@Transactional(rollbackFor = Exception.class)
public class ThemeServiceImpl extends ServiceImpl<ThemeMapper, ThemeVO> implements ThemeService {

    @Autowired
    private ThemeMapper themeMapper;

    @Override
    public List<MenuItem> getTheme() {
        return themeMapper.selectTheme();
    }

    @Override
    public IPage<ThemeVO> getThemeListByPage(Page<?> page) {
        return themeMapper.selectThemePage(page);
    }

    @Override
    public Integer getBookNumByThemeId(int themeId) {
        return themeMapper.selectBookNumByThemeId(themeId);
    }

    @Override
    public List<ThemeVO> getThemeList() {
        return themeMapper.selectThemeList();
    }

    @Override
    public List<ThemeVO> getThemeVisitedAvgData() {
        return themeMapper.selectThemeVisitedListGroupByDayAndMonthAndYearWithAvg();
    }

    @Override
    public List<ThemeVO> getThemeDownloadData() {
        return themeMapper.selectThemeDownloadListGroupByDayAndMonthAndYearWithAvg();
    }

    @Override
    public List<ThemeVO> getThemeRecommend() {
        return themeMapper.selectThemeRecommendBookNum();
    }
}
